package UDP;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public class Client {
    public static void main(String[] args) throws Exception {
        //创建一个服务区
        DatagramSocket socket=new DatagramSocket();
        //创建一个包
        //发送的内容
        String str="中国加油！";
        //获取服务区的地址
        InetAddress inetAddress=InetAddress.getByName("127.0.0.1");
        //创建访问端口号
        int port=8899;
        DatagramPacket packet=new DatagramPacket(str.getBytes(),0,str.getBytes().length,inetAddress,port);
        //发送包
        socket.send(packet);
        //关闭连接
        socket.close();
    }
}
